Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Var.split_by_season #79

Merged
merged 6 commits into from
Sep 10, 2024
Merged

Conversation

ph-kev
Copy link
Member

@ph-kev ph-kev commented Sep 9, 2024

Close #78 - This PR implement split_by_season for OutputVars. It return four OutputVars with each one corresponding to a season. This PR also add functions for converting from date to time and time to date (Utils.time_to_date, Utils.date_to_time, Utils.period_to_seconds_float).

This PR add a bug to the documentation which cause the documentation for Var.split_by_season to be ClimaAnalysis.Utils.split_by_season instead of ClimaAnalysis.Var.split_by_season.

Copy link

codecov bot commented Sep 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.55%. Comparing base (5b123f7) to head (c9c0eec).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #79      +/-   ##
==========================================
+ Coverage   96.37%   96.55%   +0.18%     
==========================================
  Files          10       10              
  Lines         607      639      +32     
==========================================
+ Hits          585      617      +32     
  Misses         22       22              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ph-kev ph-kev requested a review from Sbozzolo September 9, 2024 22:24
NEWS.md Outdated
### Split by season
`OutputVar`s can be split by seasons using `split_by_season(var)` provided that a start date
can be found in `var.attributes["start_date"]` and time is a dimension in the `OutputVar`.
The unit of time is expected to be seconds. The function `split_by_season(var)` return a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The unit of time is expected to be seconds. The function `split_by_season(var)` return a
The unit of time is expected to be seconds. The function `split_by_season(var)` returns a

docs/src/var.md Outdated
## Split by season
`OutputVar`s can be split by seasons using `split_by_season(var)` provided that a start date
can be found in `var.attributes["start_date"]` and time is a dimension in the `OutputVar`.
The unit of time is expected to be seconds. The function `split_by_season(var)` return a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The unit of time is expected to be seconds. The function `split_by_season(var)` return a
The unit of time is expected to be seconds. The function `split_by_season(var)` returns a

src/Var.jl Outdated
error("Start date is not found in var")

season_dates =
split_by_season(time_to_date.(start_date, var.dims[time_name(var)]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
split_by_season(time_to_date.(start_date, var.dims[time_name(var)]))
split_by_season(time_to_date.(start_date, times(var)))

src/Var.jl Outdated
season_data = (
_data_at_dim_vals(
var.data,
var.dims[time_name(var)],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var.dims[time_name(var)],
times(var),

@ph-kev ph-kev marked this pull request as draft September 10, 2024 00:29
@ph-kev ph-kev marked this pull request as ready for review September 10, 2024 17:41
NEWS.md Show resolved Hide resolved
src/Var.jl Outdated Show resolved Hide resolved
test/test_Var.jl Outdated Show resolved Hide resolved
test/test_Var.jl Outdated Show resolved Hide resolved
test/test_Var.jl Outdated Show resolved Hide resolved
test/test_Var.jl Outdated Show resolved Hide resolved
Also, add Utils.period_to_seconds_float. These functions are
functionally identical to the equivalent functions in ClimaUtilities. We
do not export from ClimaUtilities because we do not want to add
ClimaUtilities as a dependency.
We do this because we want to show the documentation for
Var.split_by_season and not Utils.split_by_season.
Bug introduced: The documentation show the wrong module name for
Var.split_by_season. It is ClimaAnalysis.Utils.split_by_season instead
of ClimaAnalysis.Var.split_by_season.
@ph-kev ph-kev merged commit ffb539d into CliMA:main Sep 10, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add split_by_season for OutputVar
2 participants